package com.trkj.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.trkj.pojo.Email;

public interface EmailDAO extends JpaRepository<Email, Integer>,JpaSpecificationExecutor<Email>  {
	@Query("select e from Email e where e.emp.empId=?1 and e.emailState=?2 order by e.emailStartdate desc")
	public List<Email> querymakedemail(Integer empid,String emailstate);
	
	@Query("select e from Email e where e.emailEmails=?1 order by e.emailStartdate desc")
	public List<Email> queryreservefirst(String emailemails);
	
	@Query("select e from Email e where e.emailEmails=?1 and e.emailId=?2")
	public Email queryreservebyemailidandemailemail(String emailemails,Integer emailid);
	
	@Query("select e from Email e where e.emailId=?1")
	public Email queryreservebyemailid(Integer emailid);
	
	@Query("update Email e set e.emailEnddate=?1 where e.emailId=?2")
	public Email generalemaildoreserve(Date date,Integer emailid);
	
	@Query("select e from Email e where e.emailEmails=?1")
	public List<Email> selectemailbyreserveemail(String oldemail);
	
	@Query("update Email e set e.emailEmails=?1 where e.emailId=?2")
	public void updatereserveemailbyemailid(String email,Integer emailid);
	
	@Query("select e from Email e order by e.emailStartdate desc")
	public List<Email> queryallemailbydatedesc();
}
